$(function () {
    $("#sendMsg").click(function () {
        let phone = $("input[name='telNumber']").val();
        let form_data = {phone: phone};
        console.log(form_data);
        $.post('/fr/index/sms', form_data, function (res) {
            console.log(res);
            if (res.code == 200) {
                alert("验证码发送成功");
                console.log(res.data);
                $("#hideMsg").val(res.data);
            } else {
                alert("发送失败");
            }
        })
    })
})

$(function () {
    $("#registerSubmit").click(function () {
        let telNumber = $("input[name='telNumber']").val();
        let password = $("input[name='password']").val();
        let passwordAgain = $("input[name='passwordAgain']").val();
        let code = $("#msg").val();
        let form_data = {
            phone:telNumber,
            password:password,
            passwordAgain:passwordAgain,
            code:code
        }
        // console.log(form_data);
        $.ajax({
            type: 'post',
            url: '/fr/index/register',
            contentType: 'application/json',
            dataType: 'json',
            data: JSON.stringify(form_data),
            success:function(res) {
                console.log(res);
                if ("200" == res.code && code == $("#hideMsg").val()) {
                    alert("注册成功");
                } else if (res.code == "400") {
                    alert("验证码错误");
                } else if (res.code == "401") {
                    alert("此号码已被注册");
                } else if (res.code == "300") {
                    alert("两次密码输入错误，请重新确认密码");
                }else if (res.code == "301") {
                    alert("密码不能为空");
                }
            }
        })
    })
})